import { CellRenderer } from "../../../../fl/controls/listClasses/CellRenderer";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { BaseItem } from "../common/BaseItem";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { ItemData } from "../../resource/info/ItemData";
import { ColorConfig } from "../../resource/ColorConfig";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { DataEvent } from "../../events/DataEvent";
import { GModuleEvent } from "../../mvc/GModuleEvent";
import { ShopItemInfo } from "../../resource/info/ShopItemInfo";
import { GNumericStepper } from "../../../../com/mui/controls/GNumericStepper";
//class TradeGoodsRenderer
    
    export  class TradeGoodsRenderer extends CellRenderer
    {
        constructor()
        {
            super();
            var loc1=ObjCreate.createBg(0, 0, 140, 42, this);
            var loc2=GlobalClass.getBitmap("PackItemBg");
            loc2.x = 3;
            loc2.y = 2;
            addChild(loc2);
            var loc3=new Object /* flash.display.Sprite */();
            loc3.graphics.beginFill(16711680, 0);
            loc3.graphics.drawRect(0, 0, 120, 40);
            loc3.cacheAsBitmap = true;
            addChild(loc3);
            this.mouseChildren = true;
            this.pic = new BaseItem();
            this.pic.isDragAble = false;
            this.pic.isThrowAble = false;
            this.pic.isDropAble = true;
            this.pic.setSize(32, 32);
            this.pic.y = 5;
            this.pic.x = 6;
            addChild(this.pic);
            this.pic.buttonMode = false;
            this.pic.mouseChildren = false;
            var loc4;
            (loc4 = new Object /* flash.display.Sprite */()).graphics.beginFill(16711680, 0);
            loc4.graphics.drawRect(0, 0, 120, 40);
            loc4.cacheAsBitmap = true;
            this.setStyle("upSkin", loc4);
            this.setStyle("downSkin", loc4);
            this.setStyle("overSkin", loc4);
            this.setStyle("selectedDownSkin", loc4);
            this.setStyle("selectedOverSkin", loc4);
            this.setStyle("selectedUpSkin", loc4);
            this.itemNameLabel = new GLabel();
            addChild(this.itemNameLabel);
            this.itemNameLabel.x = 42;
            this.itemNameLabel.y = 10;
            this.mouseChildren = true;
            return;
        }

        public get itemData(): ItemData
        {
            return this.pic.itemData;
        }

        public set itemData(arg1: ItemData)
        {
            var loc1=null;
            this._itemData = arg1;
            this.pic.itemData = this._itemData;
            if (this._itemData) 
            {
                loc1 = ColorConfig.instance.getItemColor(this._itemData.itemInfo.item.color);
                this.itemNameLabel.htmlText = HTMLUtil.addColor(this._itemData.itemInfo.item.name, loc1.color);
                this.pic.addEventListener(flash.events.MouseEvent.CLICK, this.onItemClick);
            }
            else 
            {
                this.itemNameLabel.htmlText = "";
                this.pic.removeEventListener(flash.events.MouseEvent.CLICK, this.onItemClick);
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=0;
            super.data = arg1;
            if (arg1) 
            {
                this.itemData = arg1["itemData"];
                if (arg1["dragAble"]) 
                {
                    this.pic.isDragAble = true;
                }
                else 
                {
                    this.pic.isDragAble = false;
                }
                if (this.itemData) 
                {
                    this.pic.itemData = this.itemData;
                    this.pic.amount = arg1["amount"];
                }
            }
            else 
            {
                this.pic.source = null;
                this.pic.amount = 0;
            }
            return;
        }

        public /* override */ set label(arg1: string)
        {
            return;
        }

        /* internal  */onItemClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            dispatchEvent(new DataEvent(GModuleEvent.Event_DeleteItem, this.listData.index, false, true));
            return;
        }

        /* internal */ /* var */_source: string;

        /* internal */ /* var */pic: BaseItem;

        /* internal */ /* var */itemNameLabel: GLabel;

        /* internal */ /* var */itemAttrLabel: GLabel;

        /* internal */ /* var */buyButton: GLabel;

        /* internal */ /* var */_itemData: ItemData;

        /* internal */ /* var */_buyItemInfo: ShopItemInfo;

        /* internal */ /* var */numStepper: GNumericStepper;

        /* internal */ /* var */buyNumBg: Object /* flash.display.Bitmap */;
    }
